package com.codebattery.controller;

import com.codebattery.service.CustomerService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("/customer")
public class CustomerController {
    private static final Logger LOGGER = LoggerFactory.getLogger(CustomerController.class);
    @Autowired
    private CustomerService customerService;

    @ApiOperation(value="查询用户订单",notes="")
    @RequestMapping(value="get-all-orders",method = RequestMethod.GET)
    @ResponseBody
    public List<Object> getAllOrders() throws ExecutionException, InterruptedException {
        CompletableFuture<List<Object>> allUserInfosFuture = customerService.getAllUserInfos(null);
        return allUserInfosFuture.get();
    }
}